package com.syzg.common.controller;

import com.syzg.common.model.WebInfo;
import com.syzg.common.model.WebObj;
import com.syzg.core.exception.ServiceException;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

@Controller
public class BaseController
{
  public void handleException(Exception e)
  {
    if ((e instanceof ServiceException)) {
      e.printStackTrace();
    }
    else
      e.printStackTrace();
  }

  public void setControllerStatus(WebObj webObj, String actionStatus)
  {
    webObj.getWebInfo().setActionStatus(actionStatus);
  }

  @InitBinder
  protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
    binder.registerCustomEditor(Date.class, new CustomDateEditor(false));
  }
}